{include file="public/layout" /}
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<body class="eyou_body_xin">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="order/left" /}
<div id="geduan_div" class="h15"></div>
<div class="page" style="min-width:auto;margin-left:115px;">
    <div class="fixed-bar">
        <div class="item-title">
            <ul class="tab-base nc-row">
                <li>
                    <a href="{:url('ShopService/after_service')}" {if condition="!$Request.param.queryStatus"}class="current"{/if}>全部</a>
                </li>
                <li>
                    <a href="{:url('ShopService/after_service', ['queryStatus'=>1])}" {eq name="$Request.param.queryStatus" value="1"}class="current"{/eq}>待处理</a>
                </li>
                <li>
                    <a href="{:url('ShopService/after_service', ['queryStatus'=>2])}" {eq name="$Request.param.queryStatus" value="2"}class="current"{/eq}>处理中</a>
                </li>
                <li>
                    <a href="{:url('ShopService/after_service', ['queryStatus'=>3])}" {eq name="$Request.param.queryStatus" value="3"}class="current"{/eq}>已完成</a>
                </li>
            </ul>
            <div class="fr e-export">
                <a href="javascript:void(0);" onclick="orderExcelExport(this);" data-url="{:url('Order/ajax_order_excel_export')}"><i class="iconfont e-XLStubiao"></i>导出订单</a>
            </div>
        </div>
    </div>
    <div class="flexigrid flexigrid-xin">
        <div class="header-bar">
            <div class="more">
                <div class="search">
                    <div class="content">
                        <form id="searchForm" action="{:url('ShopService/after_service')}" method="get" onsubmit="layer_loading('正在处理');" style="display: unset;">
                            {$searchform.hidden|default=''}
                            <input type="hidden" name="queryStatus" value="{$Request.param.queryStatus}">
                            <div class="ey-form-item"><label class="users-form-item-label">关键词：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <!-- 订单号查询 -->
                                            <div class="sDiv2">
                                                <input type="text" size="50" name="keywords" id="keywords" value="{$Request.param.keywords}" class="qsbox" style="width: 170px;" placeholder="订单号或服务单号...">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="ey-form-item"><label class="users-form-item-label">维权类型：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="service_type" id="service_type">
                                                    <option value="" {if condition="!$Request.param.service_type"}selected{/if}>全部</option>
                                                    <option value="3" {eq name="$Request.param.service_type" value="3"}selected{/eq}>仅退款</option>
                                                    <option value="2" {eq name="$Request.param.service_type" value="2"}selected{/eq}>退货退款</option>
                                                    <option value="1" {eq name="$Request.param.service_type" value="1"}selected{/eq}>换货</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {eq name="$Request.param.queryStatus" value="2"}
                            <div class="ey-form-item"><label class="users-form-item-label">维权状态：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="">
                                                <select name="status" id="status">
                                                    <option value="" {if condition="!$Request.param.status"}selected{/if}>全部</option>
                                                    <!-- 仅退款维权同意后，维权状态显示：待转账；32是仅退款维权(3)+维权状态(2) -->
                                                    <option value="32" {eq name="$Request.param.status" value="32"}selected{/eq}>待转账</option>
                                                    <!-- 换货、退货退款维权同意后，维权状态显示：买家待退货；122是换货维权(1)+退货退款维权(2)+维权状态(2) -->
                                                    <option value="122" {eq name="$Request.param.status" value="122"}selected{/eq}>买家待退货</option>
                                                    <option value="4" {eq name="$Request.param.status" value="4"}selected{/eq}>商家待收货</option>
                                                    <option value="5" {eq name="$Request.param.status" value="5"}selected{/eq}>商家已收货</option>
                                                    <option value="6" {eq name="$Request.param.status" value="6"}selected{/eq}>商家已发货</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {/eq}
    
                            <div class="ey-form-item"><label class="users-form-item-label">维权时间：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" name="add_time" id="eYLaydateTimeLinkage" data-max_date="{php}echo date('Y-m-d');{/php}" autocomplete="off"  class="qsbox" placeholder="维权申请时间" lay-key="1" style="width: 220px;" value="{$Request.param.add_time}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <div class="ey-form-item" style="margin-left: 20px;">
                            <div class="users-form-item-content">
                                <span class="bt-xin" onclick="orderQuery();">查询</span>
                                <span class="bt-xin-no" onclick="orderQuery('reset');">重置</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="geduan-xin"></div>
    <div class="flexigrid flexigrid-xin">
        <div class="tableDiv  bubbleInfo">
            <table cellspacing="0" cellpadding="0" class="wt100">
                <thead>
                    <tr>
                        <th abbr="article_time" axis="col6"> <div class="">商品信息</div> </th>
                        <th abbr="article_time" axis="col6" class="w240"> <div class="">单价/数量</div> </th>
                        <!-- <th abbr="article_time" axis="col6" class="w240"> <div class="">退还金额</div> </th> -->
                        <th abbr="article_time" axis="col6" class="w240"> <div class="">收货人</div> </th>
                        <th abbr="article_time" axis="col6" class="w140"> <div class="">维权类型</div> </th>
                        <th abbr="article_time" axis="col6" class="w140"> <div class="">处理状态</div> </th>
                        <th abbr="article_time" axis="col6" class="w250"> <div class="">操作</div> </th>
                    </tr>
                </thead>

                <tbody>
                {empty name="serviceList"}
                    <tr>
                        <td class="no-data" align="center" axis="col0" colspan="50">
                            <div class="no_row">
                                <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                            </div>
                        </td>
                    </tr>
                {else/}
                    {volist name="serviceList" id="vo"}
                    <tr class="order-empty"> <td colspan="8"></td> </tr>
                    <tr>
                        <td class="biaotou" colspan="8">
                             <span class="mr15">
                                <span class="mr15">订单号：{$vo.order_code} <a class="copy order_code" onclick="orderCopy('order_code');" data-clipboard-text="{$vo.order_code}"><i class="iconfont e-fuzhi basics-color" title="点击复制"></i></a></span>
                                <span class="mr15">服务单号：{$vo.refund_code} <a class="copy refund_code" onclick="orderCopy('refund_code');" data-clipboard-text="{$vo.refund_code}"><i class="iconfont e-fuzhi basics-color"></i></a></span>
                                <span class="fr"><i class="iconfont e-shijian mr5" title="点击复制"></i>{$vo.add_time}</span>
                             </span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="goods-detail">
                                <div class="goods-image"><img src="{$vo.product_img}"></div>
                                <div class="goods-info">
                                    <p class="goods-title">{$vo.product_name}</p> <p class="goods-spec">{$vo.product_spec}</p>
                                    <p class="after-sale" style="color: #939799;">订单状态：{$adminOrderStatus[$vo.order_status]|default=''}</p>
                                </div>
                            </div>
                        </td>
                        <td class=""><p>￥{$vo.product_price} x {$vo.product_num}</p></td>
                        <!-- <td class="" rowspan="1"><p>￥{$vo.refund_price}</p></td> -->
                        <td class="" rowspan="1"><p>{$vo.consignee}</p><p class="am-link-muted">{$vo.mobile}</p></td>
                        <td class="" rowspan="1">
                            {eq name="$vo.service_type" value="1"}<span class="w100 blue">换货</span>{/eq}
                            {eq name="$vo.service_type" value="2"}<span class="w100 red">退货退款</span>{/eq}
                            {eq name="$vo.service_type" value="3"}<span class="w100">仅退款</span>{/eq}
                        </td>
                        <td class="" rowspan="1">
                            {if condition="1 == $vo.status"}
                            <p><span class="zt" style="color: #ff9900;">待处理</span></p>
                            <!-- <p><span class="zt" style="color: #ff9900;">{$serviceStatus[$vo.status]|default=''}</span></p> -->
                            {elseif condition="in_array($vo.status, [2, 4, 5, 6])"}
                            <p><span class="zt f-14" style="color: #19be6b;">处理中</span></p>
                            <p><span class="zt" style="color: #19be6b;">{$serviceStatus[$vo.status]|default=''}</span></p>
                            {else}
                            <p><span class="zt f-14" style="color: #939799;">已完成</span></p>
                            <p><span class="zt" style="color: #939799;">{$serviceStatus[$vo.status]|default=''}</span></p>
                            {/if}
                        </td>
                        <td class="" rowspan="1">
                            <div class="operation" id="param_{$vo.service_id}" data-users_id="{$vo.users_id}" data-order_id="{$vo.order_id}" data-details_id="{$vo.details_id}" data-service_id="{$vo.service_id}" data-product_id="{$vo.product_id}" data-service_type="{$vo.service_type}">
                                {eq name="$vo.status" value="1"}
                                <a href="JavaScript:void(0);" onclick="setOpinionParam('param_{$vo.service_id}'); auditOpinion(2);" class="bt" title="同意申请"> 同意 </a>
                                <i></i>
                                <a href="JavaScript:void(0);" onclick="setOpinionParam('param_{$vo.service_id}'); auditOpinion(3);" class="bt" title="拒绝申请"> 拒绝 </a>
                                <i></i>
                                {/eq}
                                {if condition="2 == $vo.status && 3 == $vo.service_type"}
                                <a href="javascript:void(0);" data-href="{:url('ShopService/after_service_refund', ['service_id' => $vo.service_id])}" onclick="openFullframe(this, '维权退款处理', '800px', '60%');" class="bt" title="确认仅退款转账">转账</a>
                                <i></i>
                                {/if}
                                {eq name="$vo.status" value="4"}
                                <a href="javascript:void(0);" onclick="setOpinionParam('param_{$vo.service_id}'); auditOpinion(5);" class="bt" title="确认收货">收货</a>
                                <i></i>
                                <a href="javascript:void(0);" onclick="setOpinionParam('param_{$vo.service_id}'); auditOpinion(9);" class="bt" title="拒绝收货">拒收</a>
                                <i></i>
                                {/eq}
                                {if condition="5 == $vo.status && 2 == $vo.service_type"}
                                <a href="javascript:void(0);" data-href="{:url('ShopService/after_service_refund', ['service_id' => $vo.service_id])}" onclick="openFullframe(this, '维权退款处理', '800px', '60%');" class="bt" title="确认退货退款转账">转账</a>
                                <i></i>
                                {/if}
                                {if condition="5 == $vo.status && 1 == $vo.service_type"}
                                <a href="javascript:void(0);" data-href="{:url('ShopService/after_service_resend', ['service_id' => $vo.service_id])}" onclick="openFullframe(this, '维权重新发货', '800px', '60%');" class="bt" title="重新发货">重发</a>
                                <i></i>
                                {/if}
                                {notin name="$vo.status" value="3, 7, 9"}
                                <a href="javascript:void(0);" onclick="setOpinionParam('param_{$vo.service_id}'); auditOpinion(8);" class="bt" title="关闭维权">关闭</a>
                                <i></i>
                                {/notin}
                                <a class="bt" href="{:url('ShopService/after_service_details', array('service_id' => $vo['service_id']))}" title="维权详情">详情</a>
                            </div>
                        </td>
                    </tr>
                    {/volist}
                {/empty}
                </tbody>
            </table>
        </div>
        {notempty name="serviceList"}
        <div class="tDiv"> <div class="tDiv2"> {include file="public/page" /} </div> <div style="clear:both"></div> </div>
        {/notempty}
    </div>
</div>

<script type="text/javascript">
    $(document).keydown(function(event) {
        if (event.keyCode == 13) {
            $('#searchForm input[type=text]').each(function(index, item) {
                if ($(item).is(':focus')) {
                    $('#searchForm').submit();
                }
            });
        }
    });

    // 操作参数设置
    var postData = {
        _ajax: 1,
        users_id: 0,
        order_id: 0,
        details_id: 0,
        service_id: 0,
        product_id: 0,
        service_type: 0,
    };
    function setOpinionParam(paramID) {
        postData.users_id = $('#' + paramID).data('users_id');
        postData.order_id = $('#' + paramID).data('order_id');
        postData.details_id = $('#' + paramID).data('details_id');
        postData.service_id = $('#' + paramID).data('service_id');
        postData.product_id = $('#' + paramID).data('product_id');
        postData.service_type = $('#' + paramID).data('service_type');
    }

    // 订单查询
    function orderQuery(isReset) {
        if (isReset && 'reset' == isReset) {
            window.location.href = "{:url('ShopService/after_service')}";
        } else {
            $('#searchForm').submit();
        }
    }

    // 订单号复制
    function orderCopy(copyClass) {
        var clipboard1 = new Clipboard("." + copyClass);
        clipboard1.on("success", function(e) {
            layer.msg("复制成功");
        });
        clipboard1.on("error", function(e) {
            layer.msg("复制失败！请手办复制", {icon: 5});
        }); 
    }

    // AJAX调用下载
    function orderExcelExport(obj) {
        layer_loading('订单导出中');
        $.ajax({
            type: 'post',
            url : $(obj).attr('data-url'),
            data: {
                _ajax: 1,
                // 导出类型，维权订单固定值6
                export_type: 6,
                // 搜索条件信息，可为空
                pay_name: "{$Request.param.pay_name}",
                order_code: "{$Request.param.order_code}",
                end_time: "{$Request.param.add_time_end}",
                start_time: "{$Request.param.add_time_begin}",
                order_terminal: "{$Request.param.order_terminal}",
            },
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    window.location.href = res.url;
                } else {
                    showErrorAlert(res.msg);
                }
            },
            error: function(e) {
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    // 确认审核意见
    function auditOpinion(status) {
        var serviceType = postData.service_type;
        var typeHtml = "<span style='color: blue;'>换货</span>";
        if (2 === parseInt(serviceType)) {
            typeHtml = "<span style='color: red;'>退货退款</span>";
        } else if (3 === parseInt(serviceType)) {
            typeHtml = "<span style='color: red;'>仅退款</span>";
        }
        if (2 === parseInt(status)) {
            var confirmMsg = '确认同意 ' + typeHtml + ' 申请？';
            var confirmBtn = ['同意申请', '取消'];
        } else if (3 === parseInt(status)) {
            var confirmMsg = '确认拒绝 ' + typeHtml + ' 申请？';
            var confirmBtn = ['拒绝申请', '取消'];
        } else if (5 === parseInt(status)) {
            var confirmMsg = '确认收到买家退回的商品？';
            var confirmBtn = ['确认收货', '取消'];
        } else if (8 === parseInt(status)) {
            var confirmMsg = '确认关闭 ' + typeHtml + ' 维权？';
            var confirmBtn = ['关闭维权', '取消'];
        } else if (9 === parseInt(status)) {
            var confirmMsg = '确认拒绝收货？';
            var confirmBtn = ['拒绝收货', '取消'];
        } else {
            layer.msg('类型错误，刷新重试', {time: 1500}, function() {window.location.reload();});
        }
        layer.confirm(confirmMsg, {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: confirmBtn,
            success: function () {
                $(".layui-layer-content").css('text-align', 'left');
            },
        }, function() {
            // 确认执行
            postData.status = status;
            performOperation();
        });
    }

    // 执行审核操作
    function performOperation() {
        layer_loading('正在处理');
        $.ajax({
            url: "{:url('ShopService/after_service_handle')}",
            data: postData,
            type: 'post',
            dataType: 'json',
            success:function(res) {
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {time: 1500}, function() {
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {time: 1500});
                }
            }
        });
    }
</script>

<!-- 日期联动选择js文件 start -->
{eyou:static file="__PUBLIC__/static/common/js/ey_laydate_time_linkage.js"/}
<!-- 日期联动选择js文件 end -->

{include file="public/footer" /}
<script type="text/javascript">
    try{
        var mt20_1649209614 = sessionStorage.getItem("mt20_1649209614");
        if (mt20_1649209614 == 1){
            $("#geduan_div").removeClass("h15");
        } else {
            $("#geduan_div").addClass("h15");
        }
    }catch(e){}
</script>